﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Calendar.xaml" />
    </ResourceDictionary.MergedDictionaries>

<ControlTemplate x:Key="ChromelessButtonTemplate"
                     TargetType="{x:Type Button}">
        <Grid Background="{TemplateBinding Background}">
            <ContentPresenter x:Name="contentPresenter"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              Margin="{TemplateBinding Padding}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              RecognizesAccessKey="True"
                              Opacity="0.75" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver"
                     Value="True">
                <Setter TargetName="contentPresenter"
                        Property="Opacity"
                        Value="1" />
            </Trigger>
            <Trigger Property="IsMouseOver"
                     Value="False">
                <Setter TargetName="contentPresenter"
                        Property="Opacity"
                        Value=".5" />
            </Trigger>
            <Trigger Property="IsEnabled"
                     Value="false">
                <Setter Property="Foreground"
                        Value="#ADADAD" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="ChromelessButtonStyle"
           TargetType="{x:Type Button}">
        <Setter Property="Background"
                Value="{DynamicResource TransparentWhiteBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="HorizontalContentAlignment"
                Value="Center" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="Padding"
                Value="1" />
        <Setter Property="Template"
                Value="{StaticResource ChromelessButtonTemplate}" />
    </Style>

    <Style TargetType="{x:Type DatePicker}">
        <Setter Property="Background" Value="{DynamicResource InputBackground}" />
        <Setter Property="Foreground" Value="{DynamicResource InputText}" />
        <Setter Property="BorderBrush" Value="{DynamicResource InputBorder}" />
        <Setter Property="BorderThickness" Value="2" />
        <Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
        <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
        <Setter Property="MinHeight" Value="32"/>
        <Setter Property="MinWidth" Value="64"/>
        <Setter Property="IsTodayHighlighted" Value="True" />
        <Setter Property="SelectedDateFormat" Value="Short" />
        <Setter Property="Padding" Value="2,2,2,1"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="Focusable" Value="True" />

        <Setter Property="CalendarStyle" Value="{StaticResource {x:Type Calendar}}"/>
          
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DatePicker}">
                    <Border x:Name="LayoutRoot" BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}" 
                            Padding="{TemplateBinding Padding}">
                        <Grid x:Name="PART_Root"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Button x:Name="PART_Button"
                                    Background="{TemplateBinding Background}"                                     
                                    Grid.Column="1"
                                    Style="{StaticResource ChromelessButtonStyle}"
                                    Foreground="{TemplateBinding Foreground}"
                                    IsTabStop="False">
                                <Path Stretch="Uniform"
                                      Fill="{Binding ElementName=PART_Button, Path=Foreground, Mode=OneWay}"
                                      Data="F1 M 11.0017,36.005L 11.0017,14.002L 14.0021,14.002L 14.0021,11.0015L 19.0028,11.0015L 19.0028,14.002L 28.0039,14.002L 28.0039,11.0015L 33.0046,11.0015L 33.0046,14.002L 36.005,14.002L 36.005,36.005L 11.0017,36.005 Z M 13.0019,34.0048L 34.0047,34.0048L 34.0047,19.0027L 13.0019,19.0027L 13.0019,34.0048 Z M 16.5024,12.5017C 15.95,12.5017 15.5022,13.1734 15.5022,14.0019C 15.5022,14.8304 15.95,15.5021 16.5024,15.5021C 17.0547,15.5021 17.5025,14.8304 17.5025,14.0019C 17.5025,13.1734 17.0547,12.5017 16.5024,12.5017 Z M 30.5,12.4998C 29.9476,12.4998 29.4999,13.1715 29.4999,14C 29.4999,14.8286 29.9476,15.5002 30.5,15.5002C 31.0524,15.5002 31.5001,14.8286 31.5001,14C 31.5001,13.1715 31.0524,12.4998 30.5,12.4998 Z M 20.5994,33.0046L 18.1154,33.0046L 18.1154,23.7987C 17.2116,24.7375 16.1471,25.4314 14.9217,25.8803L 14.9217,23.3868C 15.5686,23.179 16.2709,22.7857 17.0287,22.2069C 17.7864,21.628 18.3067,20.9527 18.5895,20.1809L 20.5994,20.1809L 20.5994,33.0046 Z M 27.874,33.0046L 27.874,30.5111L 22.7286,30.5111L 22.7286,28.3822L 28.2039,20.359L 30.358,20.359L 30.358,28.3738L 31.9548,28.3738L 31.9548,30.5111L 30.358,30.5111L 30.358,33.0046L 27.874,33.0046 Z M 27.874,28.3738L 27.874,24.2551L 25.0601,28.3738L 27.874,28.3738 Z ">
                                    <Path.Width>
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="FontSize"/>
                                    </Path.Width>
                                    <Path.Height>
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="FontSize"/>
                                    </Path.Height>
                                </Path>
                            </Button>
                            <DatePickerTextBox x:Name="PART_TextBox" 
                                               Foreground="{TemplateBinding Foreground}" 
                                               HorizontalContentAlignment="Stretch"
                                               VerticalContentAlignment="Center"
                                               Focusable="{TemplateBinding Focusable}" />
                            <Popup x:Name="PART_Popup" 
                                   PlacementTarget="{Binding ElementName=LayoutRoot}"
                                   Placement="Bottom" 
                                   HorizontalOffset="-4"
                                   VerticalOffset="-5"
                                   StaysOpen="False"
                                   AllowsTransparency="True" />
                        </Grid>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="PART_TextBox" Property="Foreground" Value="{DynamicResource InputTextDisabled}" />
                        </Trigger>
                        <Trigger Property="IsFocused" Value="true">
                            <Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{DynamicResource Accent}" />
                        </Trigger>
                        <Trigger Property="IsKeyboardFocusWithin" Value="true">
                            <Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{DynamicResource Accent}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsEnabled" Value="True"/>
                                <Condition Property="IsMouseOver" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="{DynamicResource InputBackgroundHover}"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource InputBorderHover}"/>
                            <Setter Property="Foreground" Value="{DynamicResource InputTextHover}"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type DatePickerTextBox}">
        <Setter Property="Foreground" Value="{DynamicResource InputText}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Padding" Value="1,0,0,0" />
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DatePickerTextBox">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup Name="WatermarkStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0" />
                                </VisualStateGroup.Transitions>
                                <VisualState Name="Unwatermarked" />
                                <VisualState Name="Watermarked">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
                                        <DoubleAnimation Storyboard.TargetName="PART_Watermark" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Border x:Name="Border" 
                                Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Padding="{TemplateBinding Padding}">
                            <Grid x:Name="WatermarkContent"
                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                <Border x:Name="ContentElement" BorderThickness="0" Opacity="1" />
                                <Border x:Name="watermark_decorator" BorderThickness="0">
                                    <ContentControl x:Name="PART_Watermark"
                                                    Opacity="0"
                                                    Focusable="False"
                                                    IsHitTestVisible="False"
                                                    Margin="3,0"/>
                                </Border>
                                <ScrollViewer x:Name="PART_ContentHost" 
                                              Margin="0"
                                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
                            </Grid>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="PART_Watermark" Property="Foreground" Value="{DynamicResource InputTextDisabled}"/>
                        </Trigger>
                        <Trigger Property="IsReadOnly" Value="true">
                            <Setter TargetName="PART_Watermark" Property="Foreground" Value="{DynamicResource InputTextDisabled}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                    
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>